#include "choosewindow.h"

#include <qdebug.h>

#include "ui_choosewindow.h"

const int chooseWindow::icon_x = 230;

chooseWindow::chooseWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::chooseWindow) {
  ui->setupUi(this);
  this->setWindowFlags(
      Qt::FramelessWindowHint);  // 直接去掉系统提供的窗口边框，不能移动和改变窗口的大小
  this->setAttribute(Qt::WA_TranslucentBackground);

  QPixmap picture;
  picture.load(":/coni.png");
  icon = new QLabel(this);
  icon->setPixmap(picture);
  icon->setScaledContents(true);  // 自适应大小
  icon->resize(50, 50);
  icon_y[0] = ui->pushButton_7->y() + 5;
  for (int i = 1; i <= 3; i++) {
    icon_y[i] = icon_y[i - 1] + 40;
  }
  icon->move(icon_x, icon_y[0]);

  this->setWindowTitle("选择");
}

chooseWindow::~chooseWindow() { delete ui; }

void chooseWindow::on_pushButton_clicked() {
  // 返回开始界面
  startWindow *start = new startWindow;

  start->show();
  this->hide();
}

void chooseWindow::on_pushButton_2_clicked() {
  // 开始游戏，打开战斗界面
  battleWindow *battle = new battleWindow(grade, playerType);

  battle->show();
  this->close();
}

void chooseWindow::on_pushButton_6_clicked() {
  // musicPlayer.playMusic("qrc:/new/prefix1/Music/blue.ogg");
  // 战士
  ui->background->setPixmap(QPixmap(":/role2-big.png"));
  playerType = 1;
}

void chooseWindow::on_pushButton_5_clicked() {
  // musicPlayer.playMusic("qrc:/new/prefix1/Music/green.ogg");
  // 猎手
  ui->background->setPixmap(QPixmap(":/role4-big.png"));
  playerType = 2;
}

void chooseWindow::on_pushButton_7_clicked() {
  qDebug() << "选择新手难度";
  grade = 1;
  icon->move(icon_x, icon_y[grade - 1]);
}

void chooseWindow::on_pushButton_8_clicked() {
  qDebug() << "选择简单难度";
  grade = 2;
  icon->move(icon_x, icon_y[grade - 1]);
}

void chooseWindow::on_pushButton_9_clicked() {
  qDebug() << "选择困难难度";
  grade = 3;
  icon->move(icon_x, icon_y[grade - 1]);
}

void chooseWindow::on_pushButton_10_clicked() {
  qDebug() << "选择地狱难度";
  grade = 4;
  icon->move(icon_x, icon_y[grade - 1]);
}
